using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;

namespace Data_Access_Tier
{
	public class HRM_PAYINSURANCE_C67AHDData : DatabaseObjectBase
	{
		public HRM_PAYINSURANCE_C67AHDData()
		{
			Initialize(true);
		}
		public HRM_PAYINSURANCE_C67AHDData(Boolean newConnection)
		{
			Initialize(newConnection);
		}

		public Int32 HRM_PAYINSURANCE_C67AHD_Insert(Guid C67aHDID, Guid PayInsuranceTableListID, String EmployeeCode, String EmployeeName, String SocialInsuranceCode, Decimal Salary, String Time, Int32 TermAbsent, Int32 ProgressAbsent, Decimal Money, Int32 Type, String Description)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.InsertCommand = new SqlCommand("HRM_PAYINSURANCE_C67AHD_Insert");
				_dbadapter.InsertCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.InsertCommand.Connection = _dbconn;
				_trans = _dbconn.BeginTransaction();
				_dbadapter.InsertCommand.Transaction = _trans;
				_dbadapter.InsertCommand.Parameters.Clear();
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@C67aHDID", SqlDbType.UniqueIdentifier));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PayInsuranceTableListID", SqlDbType.UniqueIdentifier));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@EmployeeCode", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@EmployeeName", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@SocialInsuranceCode", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Salary", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Time", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@TermAbsent", SqlDbType.Int));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@ProgressAbsent", SqlDbType.Int));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Money", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Type", SqlDbType.Int));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar, 255));
				_dbadapter.InsertCommand.Prepare();
				SqlGuid C67aHDIDSQL = C67aHDID;
				_dbadapter.InsertCommand.Parameters["@C67aHDID"].Value = C67aHDIDSQL;
				SqlGuid PayInsuranceTableListIDSQL = PayInsuranceTableListID;
				_dbadapter.InsertCommand.Parameters["@PayInsuranceTableListID"].Value = PayInsuranceTableListIDSQL;
				SqlString EmployeeCodeSQL = EmployeeCode;
				_dbadapter.InsertCommand.Parameters["@EmployeeCode"].Value = EmployeeCodeSQL;
				SqlString EmployeeNameSQL = EmployeeName;
				_dbadapter.InsertCommand.Parameters["@EmployeeName"].Value = EmployeeNameSQL;
				SqlString SocialInsuranceCodeSQL = SocialInsuranceCode;
				_dbadapter.InsertCommand.Parameters["@SocialInsuranceCode"].Value = SocialInsuranceCodeSQL;
				SqlMoney SalarySQL = Salary;
				_dbadapter.InsertCommand.Parameters["@Salary"].Value = SalarySQL;
				SqlString TimeSQL = Time;
				_dbadapter.InsertCommand.Parameters["@Time"].Value = TimeSQL;
				SqlInt32 TermAbsentSQL = TermAbsent;
				_dbadapter.InsertCommand.Parameters["@TermAbsent"].Value = TermAbsentSQL;
				SqlInt32 ProgressAbsentSQL = ProgressAbsent;
				_dbadapter.InsertCommand.Parameters["@ProgressAbsent"].Value = ProgressAbsentSQL;
				SqlMoney MoneySQL = Money;
				_dbadapter.InsertCommand.Parameters["@Money"].Value = MoneySQL;
				SqlInt32 TypeSQL = Type;
				_dbadapter.InsertCommand.Parameters["@Type"].Value = TypeSQL;
				SqlString DescriptionSQL = Description;
				_dbadapter.InsertCommand.Parameters["@Description"].Value = DescriptionSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.InsertCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_PAYINSURANCE_C67AHD_Insert: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_PAYINSURANCE_C67AHD_Insert: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.InsertCommand != null)
					_dbadapter.InsertCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_PAYINSURANCE_C67AHD_Update(Guid C67aHDID, Guid PayInsuranceTableListID, String EmployeeCode, String EmployeeName, String SocialInsuranceCode, Decimal Salary, String Time, Int32 TermAbsent, Int32 ProgressAbsent, Decimal Money, Int32 Type, String Description)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_PAYINSURANCE_C67AHD_Update");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@C67aHDID", SqlDbType.UniqueIdentifier));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PayInsuranceTableListID", SqlDbType.UniqueIdentifier));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@EmployeeCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@EmployeeName", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@SocialInsuranceCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Salary", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Time", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@TermAbsent", SqlDbType.Int));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@ProgressAbsent", SqlDbType.Int));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Money", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Type", SqlDbType.Int));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Prepare();
				SqlGuid C67aHDIDSQL = C67aHDID;
				_dbadapter.UpdateCommand.Parameters["@C67aHDID"].Value = C67aHDIDSQL;
				SqlGuid PayInsuranceTableListIDSQL = PayInsuranceTableListID;
				_dbadapter.UpdateCommand.Parameters["@PayInsuranceTableListID"].Value = PayInsuranceTableListIDSQL;
				SqlString EmployeeCodeSQL = EmployeeCode;
				_dbadapter.UpdateCommand.Parameters["@EmployeeCode"].Value = EmployeeCodeSQL;
				SqlString EmployeeNameSQL = EmployeeName;
				_dbadapter.UpdateCommand.Parameters["@EmployeeName"].Value = EmployeeNameSQL;
				SqlString SocialInsuranceCodeSQL = SocialInsuranceCode;
				_dbadapter.UpdateCommand.Parameters["@SocialInsuranceCode"].Value = SocialInsuranceCodeSQL;
				SqlMoney SalarySQL = Salary;
				_dbadapter.UpdateCommand.Parameters["@Salary"].Value = SalarySQL;
				SqlString TimeSQL = Time;
				_dbadapter.UpdateCommand.Parameters["@Time"].Value = TimeSQL;
				SqlInt32 TermAbsentSQL = TermAbsent;
				_dbadapter.UpdateCommand.Parameters["@TermAbsent"].Value = TermAbsentSQL;
				SqlInt32 ProgressAbsentSQL = ProgressAbsent;
				_dbadapter.UpdateCommand.Parameters["@ProgressAbsent"].Value = ProgressAbsentSQL;
				SqlMoney MoneySQL = Money;
				_dbadapter.UpdateCommand.Parameters["@Money"].Value = MoneySQL;
				SqlInt32 TypeSQL = Type;
				_dbadapter.UpdateCommand.Parameters["@Type"].Value = TypeSQL;
				SqlString DescriptionSQL = Description;
				_dbadapter.UpdateCommand.Parameters["@Description"].Value = DescriptionSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_PAYINSURANCE_C67AHD_Update: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_PAYINSURANCE_C67AHD_Update: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_PAYINSURANCE_C67AHD_Disable(Guid C67aHDID, ref Boolean Enabled)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_PAYINSURANCE_C67AHD_Disable");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@C67aHDID", SqlDbType.UniqueIdentifier));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@enabled", SqlDbType.Bit));
				_dbadapter.UpdateCommand.Prepare();
				SqlGuid C67aHDIDSQL = C67aHDID;
				_dbadapter.UpdateCommand.Parameters["@C67aHDID"].Value = C67aHDIDSQL;
				_dbadapter.UpdateCommand.Parameters["@enabled"].Direction = ParameterDirection.Output;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_PAYINSURANCE_C67AHD_Disable: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_PAYINSURANCE_C67AHD_Disable: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_PAYINSURANCE_C67AHD_Delete(Guid C67aHDID)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.DeleteCommand = new SqlCommand("HRM_PAYINSURANCE_C67AHD_Delete");
				_dbadapter.DeleteCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.DeleteCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.DeleteCommand.Transaction = _trans;

				_dbadapter.DeleteCommand.Parameters.Clear();
				_dbadapter.DeleteCommand.Parameters.Add(new SqlParameter("@C67aHDID", SqlDbType.UniqueIdentifier));
				_dbadapter.DeleteCommand.Prepare();
				SqlGuid C67aHDIDSQL = C67aHDID;
				_dbadapter.DeleteCommand.Parameters["@C67aHDID"].Value = C67aHDIDSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.DeleteCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_PAYINSURANCE_C67AHD_Delete: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_PAYINSURANCE_C67AHD_Delete: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.DeleteCommand != null)
					_dbadapter.DeleteCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_PAYINSURANCE_C67AHD_Save(Guid C67aHDID, Guid PayInsuranceTableListID, String EmployeeCode, String EmployeeName, String SocialInsuranceCode, Decimal Salary, String Time, Int32 TermAbsent, Int32 ProgressAbsent, Decimal Money, Int32 Type, String Description)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_PAYINSURANCE_C67AHD_Save");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@C67aHDID", SqlDbType.UniqueIdentifier));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PayInsuranceTableListID", SqlDbType.UniqueIdentifier));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@EmployeeCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@EmployeeName", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@SocialInsuranceCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Salary", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Time", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@TermAbsent", SqlDbType.Int));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@ProgressAbsent", SqlDbType.Int));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Money", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Type", SqlDbType.Int));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Prepare();
				SqlGuid C67aHDIDSQL = C67aHDID;
				_dbadapter.UpdateCommand.Parameters["@C67aHDID"].Value = C67aHDIDSQL;
				SqlGuid PayInsuranceTableListIDSQL = PayInsuranceTableListID;
				_dbadapter.UpdateCommand.Parameters["@PayInsuranceTableListID"].Value = PayInsuranceTableListIDSQL;
				SqlString EmployeeCodeSQL = EmployeeCode;
				_dbadapter.UpdateCommand.Parameters["@EmployeeCode"].Value = EmployeeCodeSQL;
				SqlString EmployeeNameSQL = EmployeeName;
				_dbadapter.UpdateCommand.Parameters["@EmployeeName"].Value = EmployeeNameSQL;
				SqlString SocialInsuranceCodeSQL = SocialInsuranceCode;
				_dbadapter.UpdateCommand.Parameters["@SocialInsuranceCode"].Value = SocialInsuranceCodeSQL;
				SqlMoney SalarySQL = Salary;
				_dbadapter.UpdateCommand.Parameters["@Salary"].Value = SalarySQL;
				SqlString TimeSQL = Time;
				_dbadapter.UpdateCommand.Parameters["@Time"].Value = TimeSQL;
				SqlInt32 TermAbsentSQL = TermAbsent;
				_dbadapter.UpdateCommand.Parameters["@TermAbsent"].Value = TermAbsentSQL;
				SqlInt32 ProgressAbsentSQL = ProgressAbsent;
				_dbadapter.UpdateCommand.Parameters["@ProgressAbsent"].Value = ProgressAbsentSQL;
				SqlMoney MoneySQL = Money;
				_dbadapter.UpdateCommand.Parameters["@Money"].Value = MoneySQL;
				SqlInt32 TypeSQL = Type;
				_dbadapter.UpdateCommand.Parameters["@Type"].Value = TypeSQL;
				SqlString DescriptionSQL = Description;
				_dbadapter.UpdateCommand.Parameters["@Description"].Value = DescriptionSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_PAYINSURANCE_C67AHD_Save: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_PAYINSURANCE_C67AHD_Save: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public DataSet HRM_PAYINSURANCE_C67AHD_GetList()
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.SelectCommand = new SqlCommand("HRM_PAYINSURANCE_C67AHD_GetList");
				_dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.SelectCommand.Connection = _dbconn;
				_dbadapter.SelectCommand.Parameters.Clear();
				_dbadapter.SelectCommand.Prepare();
				_dbadapter.Fill(_data);

				return _data;
			}
			catch (SqlException e)
			{
				throw new Exception("SQL Error: HRM_PAYINSURANCE_C67AHD_GetList: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.SelectCommand != null)
					_dbadapter.SelectCommand.Dispose();
				CloseConnection();
			}
		}
		public DataSet HRM_PAYINSURANCE_C67AHD_Get(Guid C67aHDID)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.SelectCommand = new SqlCommand("HRM_PAYINSURANCE_C67AHD_Get");
				_dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.SelectCommand.Connection = _dbconn;
				_dbadapter.SelectCommand.Parameters.Clear();
				_dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@C67aHDID", SqlDbType.UniqueIdentifier));
				_dbadapter.SelectCommand.Prepare();
				SqlGuid C67aHDIDSQL = C67aHDID;
				_dbadapter.SelectCommand.Parameters["@C67aHDID"].Value = C67aHDIDSQL;
				_dbadapter.Fill(_data);

				return _data;
			}
			catch (SqlException e)
			{
				throw new Exception("SQL Error: HRM_PAYINSURANCE_C67AHD_Get: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.SelectCommand != null)
					_dbadapter.SelectCommand.Dispose();
				CloseConnection();
			}
		}
	}
}
